package com.example.stlink;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;

import com.example.stlink.activitys.IdChooseActivity;
import com.example.stlink.utils.CommonUtils;

/**
 * app加载活动
 */
public class LaunchActivity extends AppCompatActivity {

    private ImageView mClipLeftLoadingImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);

        mClipLeftLoadingImageView = findViewById(R.id.iv_login_loading);
        mClipLeftLoadingImageView.setImageLevel(0);

        //修改状态栏字体颜色
        CommonUtils.changeStatusBar(this);

//        //延时任务，进度条加载
//        handler.postDelayed(runnable, 500);

        //延时加载
        Handler handler = new Handler();
        handler.postDelayed(() -> {
            Intent intent = new Intent(LaunchActivity.this, IdChooseActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }, 1000);//3秒后执行Runnable中的run方法

    }


//    //开启一个子线程用作进度条加载
//    private int mUnmber = 0;
//    private Handler handler = new Handler();
//    Runnable runnable = new Runnable() {
//        @Override
//        public void run() {
//            if(mUnmber <= 10000){
//                mClipLeftLoadingImageView.getDrawable().setLevel(mUnmber);
//                handler.postDelayed(runnable, 20);
//                mUnmber += 100;
//            }
//
//            //进度条加载完毕之后，跳转到身份选择活动
//            Intent intent = new Intent(LaunchActivity.this, IdChooseActivity.class);
//            startActivity(intent);
//        }
//    };
}